<!DOCTYPE html>
<html lang="en">
<#include "../common/scripts.html">
<#include "../common/scripts_add.html">
<body>
<style>
    .table-main-2 {
        table-layout: fixed;
        word-break: break-all;
    }

    .table-main-2 th {
        border: 1px solid #DBF4FF;
        color: #0CB3FE;
    }

    .table-main-2 td {
        border: 1px solid #ccc;
    }

    .table-main-2 tr td:nth-child(odd) {
        text-align: center;
        width: 10% !important;
    }

    .table-main-2 tr td:nth-child(even) {
        width: 30% !important;
    }
</style>
<div class="page-content">
    <div class="fh-subtitle">公司管理信息</div>
    <form action="" method="post" id="editForm" class="form-horizontal">
        <input type="text"  id="id"  name="id" value="${company.id!}" class="hide">
        <table class="table-main" style="width: 80% !important;">
            <tr>
                <td style="width: 10%;"><span>上级公司</span></td>
                <td colspan="3">
                    <div class="input-group" style="width: 100%;">
                        <input type="text" class="form-control" id="parentName" name="parentName" value="${company.parentCompanyName!}" style="border: 0;" readonly <#if (company.id!)==''> placeholder="请选择" </#if>  />
                        <#if (company.id!)==''>
                        <span onclick="parentNameTree();" class="input-group-btn btn btn-default" style="border-left: 1px solid #ccc;font-size: 13px; border: 0; border-radius:0px;">
                        <i class="fa fa-search"></i></span>
                        </#if>
                    </div>
                    <input type="hidden" id = "parentId" name = "parentId">
                </td>
            </tr>
            <col style="width: 3% !important;">
            <col>
            <col style="width: 3% !important;">
            <col>
            <tr>
                <td style="width: 10%;"><#if (company.id!)==''><span class="required-flag">*</span></#if><span>公司编码</span></td>
                <td style="width: 40%;">
                    <input  class="form-control-gx" value="${company.companyCode!}" name="companyCode" id="companyCode" autocomplete="off" readonly/>
                </td>
                <td style="width: 10%;"><span class="required-flag">*</span><span>公司名称</span></td>
                <td style="width: 40%;">
                    <input  class="form-control-gx" value="${company.companyName!}" name="companyName" id="companyName" autocomplete="off"/>
                </td>
            </tr>
            <tr>
                <td ><span>公司简称</span></td>
                <td >
                    <input  class="form-control-gx" value="${company.shortName!}" name="shortName" id="shortName" autocomplete="off"/>
                </td>
                <td><span>公司电话</span></td>
                <td>
                    <input  class="form-control-gx" value="${company.phone!}" name="phone" id="phone" autocomplete="off"/>
                </td>
            </tr>
            <tr>
                <td ><span>地址</span></td>
                <td >
                    <input  class="form-control-gx" value="${company.address!}" name="address" id="address" autocomplete="off"/>
                </td>
                <td><span>排序</span></td>
                <td>
                    <input  class="form-control-gx" value="${company.sort!}" name="sort" id="sort" onkeyup="value=value.replace(/[^\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" autocomplete="off"/>
                </td>
            </tr>
            <tr>
                <td><span>说明</span></td>
                <td  colspan="3">
                    <input  class="form-control-gx" type="text" name="remark" id = "remark" value="${company.remark!}" style="height: 50px;" autocomplete="off">
                </td>
            </tr>
        </table>
    </form>
    <div class="text-center" style="width: 1000px; margin-top: 20px; ">
        <span class="model-btn" onclick="submit()" style="width:80px;">保存</span>
    </div>
</div>
<script>
    $(function(){
        var id = '${company.id!}';
        if(isEmpty(id)){
            $("#sort").val("1");
        }
    });
    function submit() {
        if(isEmpty_byJqObj($("#companyCode"))){
            sys.topmsg("公司编码不能为空");
            return false;
        }
        if(isEmpty_byJqObj($("#companyName"))){
            sys.topmsg("公司名称不能为空");
            return false;
        }
       /* if(isEmpty_byJqObj($("#sort"))){
            sys.topmsg("排序不能为空");
            return false;
        }*/
        $.ajax({
            url : "${ctx}/company/saveOrUpdate",
            type : "POST",
            datatype : "json",
            data : $('#editForm').serialize(),
            success : function(res) {
                if (res.success) {
                    js.showMessage(res.data,"","success",1500)
                    js.closeCurrentTabPage(function(contentWindow){
                        contentWindow.reload();
                    });
                } else {
                    sys.topmsg(res.message);
                }
            },
            error : function(data) {
                js.showMessage("请求异常！","","error",1500)
            }
        });
    }
    //获取上级公司
    function parentNameTree() {
        PullDownTree_obj.init("findCompanyIdTree",
            "#parentName", "", "#parentId", false, "", "", function(treeId, treeNode) {
                if(treeNode.type=="1"){
                    $("#parentName").val(treeNode.name);
                    $("#parentId").val(treeNode.id);
                    $("#ztree-container").hide();
                    return false;
                }
            });
    }
</script>
</body>
</html>